package com.topcoder.srm528;

import java.util.Arrays;

public class Cut {

	public int getMaximum(int[] eelLengths, int maxCuts) {
		Arrays.sort(eelLengths);
		int cut = maxCuts;
		int max = 0;
		
		// cut tens
		for (int i : eelLengths) {
			if (i % 10 == 0) {
				if (i/10 <= cut + 1) {
					max += i/10;
					cut -= i/10 - 1;
				}
				else {
					return max + cut;
				}
			}
		}
		
		// cut remaining
		for (int i : eelLengths) {
			if (i % 10 != 0) {
				if (i/10 <= cut) {
					max += i/10;
					cut -= i/10;
				}
				else {
					return max + cut;
				}
			}
		}
		
		return max;
	}

}
